-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[automatic-failover] Implement weighted endpoint selection #3519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[automatic-failover] Implement weighted endpoint selection #3519
Conversation
- add HealthStatus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a HealthStatus enum and refactors the failover logic to use health-based endpoint selection instead of directly checking circuit breaker states. The changes simplify the configuration by removing the RedisDatabaseConfig inner class and having RedisDatabase accept DatabaseConfig directly.
Key Changes:
- Added
HealthStatusenum with UNKNOWN, HEALTHY, and UNHEALTHY states - Refactored
RedisDatabaseto useDatabaseConfigdirectly instead of innerRedisDatabaseConfigclass - Updated failover logic in
StatefulRedisMultiDbConnectionImplto filter by health status instead of circuit breaker state
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| HealthStatus.java | New enum defining health states (UNKNOWN, HEALTHY, UNHEALTHY) for database endpoints |
| RedisDatabase.java | Removed inner RedisDatabaseConfig class, added healthStatus field with getter, updated constructor to accept DatabaseConfig directly |
| StatefulRedisMultiDbConnectionImpl.java | Renamed getHealthyDatabase to getNextHealthyDatabase, changed filtering from circuit breaker state to health status, improved error handling with orElse(null) |
| MultiDbClientImpl.java | Simplified database creation by passing DatabaseConfig directly instead of wrapping in RedisDatabaseConfig |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
tishun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have any general concerns beside the assumption this is a partial change and this is why the health state is not mutable at all (as far as I can tell)
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
- rename predicate function - add javadoc
ggivo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tishun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| * | ||
| * This file contains contributions from third-party contributors | ||
| * licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new files we can omit this part, only the first 3 lines are required
5f3060f
into
redis:feature/automatic-failover-1
There is half baked weighted endpoint selection in current implementation. This PR introduces the proper health status check while improves the overall quality of the code.
HealthStatusEnumRedisDatabase.RedisDatabaseConfiginner classRedisDatabasenow acceptsDatabaseConfigdirectlygetNextHealthyDatabase